from app.app import create_app
import time
from fastapi import Request
# 容器运行入口
app = create_app()


@app.middleware("http")
async def add_process_time(request: Request, call_next):
    start_time = time.perf_counter()
    # body = await request.body()
    # print(body)
    response = await call_next(request)
    process_time = time.perf_counter() - start_time
    response.headers["X-Process-Time"] = str(process_time)
    return response


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, host='0.0.0.0', port=8000)
